package cn.lqz.bucttrain.controller;

import cn.lqz.bucttrain.pojo.vo.ResponseVO;
import cn.lqz.bucttrain.service.DataBaseService;
import cn.lqz.bucttrain.utils.ResponseUtils;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/database")
public class DataBaseController {
    @Resource
    private DataBaseService dataBaseService;

    /**
     * 数据库备份在服务器上
     * @param folderPath
     * @return
     */
    @PostMapping("/backupServer")
    public ResponseVO backupServer(String folderPath){
        dataBaseService.backupServer(folderPath);
        return ResponseUtils.success();
    }

    /**
     * 数据库备份到本地
     * @param httpServletResponse
     */
    @PostMapping("/backupLocal")
    public void backupLocal(HttpServletResponse httpServletResponse){
        dataBaseService.backupLocal(httpServletResponse);
    }
}
